/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package AdminManagerment.chart;

import java.awt.Color;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

/**
 *
 * @author Tngoc
 */
public class InterviewBySchedulerChart {
    
    private JFrame root;
    private DefaultCategoryDataset dataset;
    private JFreeChart chart;
    private ChartFrame frame;

    public InterviewBySchedulerChart(JFrame root,DefaultCategoryDataset dataset) {
        this.root = root;
        this.dataset = dataset;
        chart = ChartFactory.createBarChart("Intervew of all Scheduler", "Scheduler", "time", dataset,
                PlotOrientation.HORIZONTAL, true, true, false);
        CategoryPlot p = chart.getCategoryPlot();
        frame = new ChartFrame("Bar Chart", chart);
    }

    public DefaultCategoryDataset getDataset() {
        return dataset;
    }

    public void setDataset(DefaultCategoryDataset dataset) {
        this.dataset = dataset;
    }
    
    public void showChart(){
        root.setEnabled(false);
        frame.addWindowListener(new WindowListener() {

            @Override
            public void windowOpened(WindowEvent e) {
            }

            @Override
            public void windowClosing(WindowEvent e) {
                root.setEnabled(true);
            }

            @Override
            public void windowClosed(WindowEvent e) {
            }

            @Override
            public void windowIconified(WindowEvent e) {
            }

            @Override
            public void windowDeiconified(WindowEvent e) {
            }

            @Override
            public void windowActivated(WindowEvent e) {
            }

            @Override
            public void windowDeactivated(WindowEvent e) {
            }
        });
        frame.setVisible(true);
        frame.setSize(400, 350);
    }
}
